<template>
  <div class=""></div>
</template>

<script>
export default {
  props: {},
  components: {
    // components: (reslove) => {
    // require(['', reslove]);
    // }
  },
  data() {
    return {};
  },
  created() {
    this.initDataFun(); //初始化数据
  },
  mounted() {},
  beforeDestroy() {},
  watch: {},
  computed: {},
  methods: {
    //初始化数据
    initDataFun() {
      function person(name) {
        this.name = name;
      }
      const personA = new person('a');
      console.log(Object.getPrototypeOf({}) === Object.prototype);
      console.log(Object.getPrototypeOf(personA) === person.prototype);
      console.log(this.myIntanceof(personA, person));
      console.log(this.myIntanceof({}, Object));
    },
    myIntanceof(a, b) {
      if (!['object', 'array', 'function'].includes(typeof a)) return false;
      // 获取对象的原型
      let proto = Object.getPrototypeOf(a); // => a.__proto__ 隐式原型
      // 获取构造函数的 prototype 对象
      let prototype = b.prototype;

      // 判断构造函数的 prototype 对象是否在对象的原型链上
      // eslint-disable-next-line no-constant-condition
      while (true) {
        if (!proto) return false; // 原型链顶端，还未找到
        if (proto === prototype) return true;
        // 如果没有找到，就继续从其原型上找，Object.getPrototypeOf方法用来获取指定对象的原型
        proto = Object.getPrototypeOf(proto);
      }
    },
  },
};
</script>

<style lang="less"></style>

<style lang="less" scoped></style>
